package com.medical.data.domain;

import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.TypeReference;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.springframework.data.annotation.Transient;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;

/**
 * <p>
 *
 * </p>
 *
 * @author cj
 * @since 2024-02-06
 */

@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "FormData对象", description = "")
@TableName(autoResultMap=true)
public class FormData implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.ASSIGN_UUID)
    private String id;

    @NotBlank(message = "节点id不可为空")
    private String nodeId;

    @NotBlank(message = "表单id不能为空")
    private String formId;

    @ApiModelProperty(value = "医生名字")
    private String doctorName;

/*    @NotBlank(message = "填写的数据不能为空")
    @ApiModelProperty(value = "填写的数据不能为空")
    private String originalData;*/

    @NotNull(message = "填写的数据不能为空")
    @ApiModelProperty(value = "填写的数据不能为空Json格式")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private JSONObject originalDataJson;

    @ApiModelProperty(value = "序号")
    private Long serialNumber;

    @ApiModelProperty(value = "提交ua")
    private String submitUa;

    @ApiModelProperty(value = "提交系统")
    private String submitOs;

    @ApiModelProperty(value = "提交浏览器")
    private String submitBrowser;

    @ApiModelProperty(value = "请求ip")
    private String submitRequestIp;

    @ApiModelProperty(value = "提交地址")
    private String submitAddress;

    @ApiModelProperty(value = "完成时间 毫秒")
    private Integer completeTime;

    @ApiModelProperty(value = "微信openId")
    private String wxOpenId;

    @ApiModelProperty(value = "微信用户信息")
    private String wxUserInfo;

    @ApiModelProperty(value = "扩展字段记录来源等")
    private String extValue;

    @TableLogic
    @ApiModelProperty(value = "软删除：0代表未删除1代表删除")
    private Boolean isDelete;

    @Version
    @ApiModelProperty(value = "版本号")
    private Integer version;

    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty(value = "更新时间")
    private Date updateTime;

    @NotBlank(message = "患者id不能为空")
    @ApiModelProperty(value = "患者id")
    private String patientId;

    @ApiModelProperty(value = "填写状态")
    private Boolean status;

    @Transient
    @ApiModelProperty(value = "项目Id")
    private String projectId;




/*    public void setOriginalData(String originalData) {
        this.originalData = originalData;
        this.setOriginalDataJson(JSONObject.parseObject(originalData));
    }*/

    /*    public FormData() {
    }

    public FormData(String id, String formId, String doctorName, String originalData, JSONObject originalDataJson, Long serialNumber, String submitUa, String submitOs, String submitBrowser, String submitRequestIp, String submitAddress, Integer completeTime, String wxOpenId, String wxUserInfo, String extValue, Boolean isDelete, Integer version, Date createTime, Date updateTime) {
        this.id = id;
        this.formId = formId;
        this.doctorName = doctorName;
        this.originalData = originalData;
        this.originalDataJson = JSONObject.parseObject(originalData);
        this.serialNumber = serialNumber;
        this.submitUa = submitUa;
        this.submitOs = submitOs;
        this.submitBrowser = submitBrowser;
        this.submitRequestIp = submitRequestIp;
        this.submitAddress = submitAddress;
        this.completeTime = completeTime;
        this.wxOpenId = wxOpenId;
        this.wxUserInfo = wxUserInfo;
        this.extValue = extValue;
        this.isDelete = isDelete;
        this.version = version;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }
    */

    /*

    public void setId(String id) {
        this.id = id;
    }

    public void setFormId(String formId) {
        this.formId = formId;
    }

    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }


/*    public void setOriginalData(String originalData) {
        this.originalData = originalData;
        this.setOriginalDataJson(JSONObject.parseObject(originalData, new TypeReference<Map<String, Object>>() {
        }));
    }*/

    /*public void setOriginalDataJson(Map<String, Object> originalDataJson) {
        this.originalDataJson = originalDataJson;
    }

    public void setSerialNumber(Long serialNumber) {
        this.serialNumber = serialNumber;
    }

    public void setSubmitUa(String submitUa) {
        this.submitUa = submitUa;
    }

    public void setPatientId(String patientId) {
        this.patientId = patientId;
    }

    public void setStatus(Boolean status) {
        this.status = status;
    }

    public void setSubmitOs(String submitOs) {
        this.submitOs = submitOs;
    }

    public void setSubmitBrowser(String submitBrowser) {
        this.submitBrowser = submitBrowser;
    }

    public void setSubmitRequestIp(String submitRequestIp) {
        this.submitRequestIp = submitRequestIp;
    }

    public void setSubmitAddress(String submitAddress) {
        this.submitAddress = submitAddress;
    }

    public void setCompleteTime(Integer completeTime) {
        this.completeTime = completeTime;
    }

    public void setWxOpenId(String wxOpenId) {
        this.wxOpenId = wxOpenId;
    }

    public void setWxUserInfo(String wxUserInfo) {
        this.wxUserInfo = wxUserInfo;
    }

    public void setExtValue(String extValue) {
        this.extValue = extValue;
    }

    public void setDelete(Boolean delete) {
        isDelete = delete;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }


    */
}
